package com.sky.service.user.impl;

import com.sky.entity.Setmeal;
import com.sky.mapper.SetmealMapper;
import com.sky.service.user.SetmealService;
import com.sky.vo.DishItemVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("userSetmealService")
@Slf4j
public class SetmealServiceImpl implements SetmealService {

    private final SetmealMapper setmealMapper;

    @Autowired
    public SetmealServiceImpl(SetmealMapper setmealMapper) {
        this.setmealMapper = setmealMapper;
    }

    /**
     * 根据套餐查询套餐
     *
     * @param setmeal 套餐实体类
     * @return 套餐集合
     */
    @Override
    public List<Setmeal> listSetmeal(Setmeal setmeal) {
        log.info("执行 根据套餐实体类查询套餐 业务:{}",setmeal);
        return setmealMapper.listSetmeal(setmeal);
    }

    /**
     * 根据套餐id查询包含的菜品列表
     *
     * @param setmealId 套餐id
     * @return 菜品VO
     */
    @Override
    public List<DishItemVO> getDishItemBySetmealId(Long setmealId) {
        log.info("执行 根据套餐id查询菜品关联表 业务: {}" ,setmealId);
        return setmealMapper.getDishItemById(setmealId);
    }
}
